package com.atguigu.transform;

import org.apache.flink.api.common.functions.MapFunction;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @author wky
 * @create 2021-07-14-11:01
 */
public class Transform_Union {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment senv = StreamExecutionEnvironment.getExecutionEnvironment();
        //senv.setParallelism(1);
        DataStreamSource<String> streamSource1 = senv.fromElements("1, 2, 3, 4, 5, 6");
        DataStreamSource<String> streamSource2 = senv.fromElements("a", "b", "c", "d");
        DataStreamSource<String> streamSource3 = senv.fromElements("1", "2", "3", "4");
        DataStream<String> union = streamSource1.union(streamSource2).union(streamSource3);
        union.map(new MapFunction<String, String>() {
            @Override
            public String map(String s) throws Exception {

                return s+"1";
            }
        }).print();
        senv.execute();

    }
}
